

<div id="main" role="main">
		<div class="tab-content tab-addtabs">
			<div id="content">
				<div class="row">
					<div class="col-xs-12 col-sm-12 col-md-12 col-lg-12">
						 <div class="content">
							<form class="layui-form" >
								<div class="layui-form-item">
									<label class="layui-form-label">部门名称：</label>
									<div class="layui-input-block">
										<input type="text" id="name" placeholder="部门名称" class="layui-input" value="{$info.s_name}">
									</div>
								</div>
								
								<div class="layui-form-item">
									<label class="layui-form-label">部门编码：</label>
									<div class="layui-input-block">
										<input type="text" id="code" placeholder="唯一，例如：0001" class="layui-input" value="{$info.s_code}">
									</div>
								</div>
								<div class="layui-form-item">
									<label class="layui-form-label">排序：</label>
									<div class="layui-input-block">
										<input type="text" id="sort" placeholder="排序，越大越靠前" class="layui-input" value="{$info.s_sort}">
									</div>
								</div>
									
								<div class="layui-form-item">
									<label class="layui-form-label">上级部门：</label>
									<div class="layui-input-block" id="pid" data-id="{$info.s_pid}">
										<input type="text" value="{$name}" disabled class="layui-input">
									</div>
								</div>
								
								<div class="layui-form-item">
									<label class="layui-form-label">公共角色：</label>
									<div class="layui-input-block">
										{volist name="role" id="v"}
										<input type="radio" name="role" title="{$v.r_name}" value="{$v.r_id}" {eq name="info.r_id" value="$v['r_id']"}checked{/eq}>
										{/volist}
									</div>
								</div>

								<div class="layui-form-item layui-form-text">
									<label class="layui-form-label">备 注：</label>
									<div class="layui-input-block">
										<textarea name="desc" placeholder="可为空" class="layui-textarea" id="remark" rows="4">{$info.s_remark}</textarea>
									</div>
								</div>
							</form>
						</div>
					</div>
				</div>
			</div>
		</div>
	</div>


<script>
layui.use(['form'], function(){
var form = layui.form;
});

function doSubimt() {
	var res;
	var name        = $('#name').val();
    var pid         = $('#pid').attr('data-id');
    var code        = $('#code').val();
    var sort        = $('#sort').val();
    var remark      = $('#remark').val();
	var role        = $("input[name='role']:checked").val();

    var data        = {'id':{$id}, 'name':name,'pid':pid,'code':code,'sort':sort,'remark':remark, 'role':role};
    if (name == '') {
		$.tooltip();$.thinkmimi({Content : '部门名称不能为空！', Type:2, Align:'right', OutTime:2000});return false;
	}
	if (!role) {
		$.thinkmimi({Content : '请选择对应的角色！', Type:2, Align:'right', OutTime:2000});return false;
	}
	$.ajax({
		type: 'post',
		data: data,
		async: false,
		url: "{:url('upd')}",
		success: function(data) {
			var array = eval('('+data+')');
			res = array;
			if (array['code'] == '01') {
				$.thinkmimi({Content : array['msg'], Type:2, Align:'right', OutTime:2000});
				res = false;
			}
		}
	});
	return res;
}
</script>